<template>
  <div class="feedback">
    <v-header :back-display="true">
      <div slot="title">意见反馈</div>
    </v-header>

    <div class="feed-title">问题分类</div>
    <div class="table">
      <div class="tab-item" v-for="(item,index) in list" :key="index" :class="activeClass == index? 'active':'' " @click="IsActive(index,item.id)">{{item.title}}</div>
    </div>

    <div class="feed-title">反馈内容</div>
    <div class="feed-input">
      <textarea v-model="formlist.message" placeholder="在此填写反馈内容"></textarea>
    </div>
    <div class="upimg">
      <van-uploader v-model="formlist.imgs" multiple :max-count="4" />
    </div>

    <div class="feed-title">联系方式</div>
    <div class="contact">
      <input type="text" v-model="formlist.phone" placeholder="输入您的联系方式">
    </div>

    <div class="bottom-btn">
      <van-button block type="info" @click="onSubmit">提 交</van-button>
    </div>
  </div>
</template>

<script>
import header from '@/components/main/header'
import { Button, Uploader, Toast } from 'vant';

export default {
  name: 'feedback',
  components: {
    "v-header":header,
    [Uploader.name]: Uploader,
    [Button.name]: Button,
    [Toast.name]: Toast,
  },
  data () {
    return {
      activeClass: 0, // 默认选中第一个
      list: [
        { id:'功能建议', title: '功能建议'},
        { id:'性能建议', title: '性能建议'},
      ],
      formlist: {
        id: "功能建议",
        message: "",
        imgs: [],
        phone:'',  //联系方式  手机  微信  QQ  不定
      },
    }
  },
  created () {},
  computed: {},
  methods: {
    // 问题分类
    IsActive(index,id){
      this.activeClass=index;
      console.log('问题分类id: '+id);
      this.formlist.id=id
    },


    // 提交表单
    onSubmit() {
      if( this.formlist.message.length < 8 ){
        Toast('内容至少8个字');
      }else if( this.formlist.phone.length < 1 ){
        Toast('请填写联系方式');
      }else{
        console.log('提交意见反馈: ', this.formlist,);
        Toast.success('提交成功');
        setTimeout(()=>{
          this.$router.push({path:'/user'})
        },2000)
      }
    },
  },
  mounted () {
  }
}
</script>

<style lang="less" scoped>
.feedback{
  position:absolute;
  width: 100%;
  height: 100%;
  top:0;
  left: 0;
  background-color: #f1f1f1;
}
.feed-title{
  font-size: 14px;
  line-height: 36px;
  color: #666;
  padding-left: 15px;
}
.table{
  height: 80px;
  display: flex;
  align-items: center;
  background: #fff;
  .tab-item{
    width: 80px;
    margin-left: 30px;
    border: 1px solid #666;
    font-size: 12px;
    color: #666;
    text-align: center;
    border-radius: 5px;
    line-height: 32px;
  }
  .active{
    color: #ff8333;
    border-color: #ff8333;
    box-shadow: 0 2px 6px 0 rgba(0, 0, 0, .1);
  }
}
.feed-input{
  height: 90px;
  padding: 10px 12px 15px 13px;
  background-color: #fff;
  textarea{
    background-color:transparent;
    font-size: 14px;
    color: #333;
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
    line-height: 20px;
    text-align: justify;
    resize: none;
  }
  textarea::-webkit-input-placeholder{
    color: #666;
  }
  textarea::-webkit-scrollbar-track-piece{
    background-color: transparent;
  }
  textarea::-webkit-scrollbar-thumb:vertical {
    background-color: transparent;
  }
}
.van-button--info {
  background-color: #ff8333;
  border-color: #ff8333;
  font-size: 16px;
}
.bottom-btn{
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
}
.upimg{
  background-color: #fff;
  .van-uploader {margin-left: 15px;}
}
/deep/.van-uploader__preview-image {
  width: 60px;
  height: 60px;
}
/deep/.van-uploader__upload {
    width: 60px;
    height: 60px;
}
.contact{
  background: #fff;
  input{
    background-color: transparent;
    font-size: 14px;
    color: #333;
    display: inline-block;
    width: 100%;
    padding: 13px 15px;
    box-sizing: border-box;
  }
  input::-webkit-input-placeholder{
    color: #666;
  }
}
</style>
